Skip to content

Conversation

brandonpayton
Copy link
Member

@brandonpayton brandonpayton commented Aug 16, 2025

Motivation for the change, related issues

Applying a Blueprint to an existing site is not possible with the Blueprints v2 runner as it always runs in the create-new-site mode, not in the apply-to-existing-site mode. This PR exposes an explicit --mode option

Related to #2508

Implementation details

This PR exposes a mode CLI option for use with Blueprints v2.

For migration convenience, this PR also rewrites a few v1 options (e.g. --skipWordpressSetup) into v2 options (e.g. --mode=apply-to-existing-site). There are appropriate safeguard in place to prevent options conflicts.

In the categories of bonus, controversial, and up for discussion, this PR also expands the auto-mount option to allow passing an explicit path to auto-mount. If no path is passed the option defaults the current working directory. This is a nice feature IMO, and it also makes testing the CLI feature using npx nx unbuilt-jspi playground-cli (since the current directory for that command is typically the project root).

Testing Instructions (or ideally a Blueprint)

  • CI

@brandonpayton brandonpayton requested a review from a team August 16, 2025 02:48
@brandonpayton brandonpayton self-assigned this Aug 16, 2025
@brandonpayton brandonpayton added [Type] Bug An existing feature does not function as intended [Package][@wp-playground] CLI labels Aug 16, 2025
@brandonpayton
Copy link
Member Author

I adapted the existing run-cli tests to also test using --experimental-blueprints-v2-runner. The tests are not yet passing, but once we address the failures, we should have the same CLI test coverage for Blueprints v2 as we do for v1.

I'd also like to add more tests specific to Blueprints v2 as part of this PR.

* Playground should not modify the mounted directory.
*/
expect(await getDirectoryChecksum(tmpDir)).toBe(checksum);
expect(response.text).toContain('<title>My Blog Name</title>');
});

test('should be able to follow external symlinks in primary and secondary PHP instances', async () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was incorrectly included within the auto-mount tests, so this is just moving it where it belongs.

@brandonpayton
Copy link
Member Author

Observation:
These tests are timing out when on a slow connection. Maybe some of our test timeouts in CI are due to each test downloading a full copy of WordPress and sqlite-database-integration.

Maybe we should explore HTTPS caching during unit test.

@brandonpayton
Copy link
Member Author

Not all the pre-existing run-cli tests have to pass for this PR, but the remaining test failures are:

  • "should be able to follow external symlinks in primary and secondary PHP instances"
  • "should run a wp-content project using --auto-mount" -- Playground CLI complains that it cannot connect to the DB
  • "should run a wordpress project using --auto-mount" -- the blueprints v2 runner complains "The target site exists but WordPress is not properly installed or configured". This makes sense because it is mounting a freshly unzipped WordPress download.

For this PR to be merged, I believe the following need to be done:

  • Add a couple of Playground CLI Blueprints v2 tests for the manual --mode option in combination with --mount-before-install or --mount-dir-before-install.
  • Split the --auto-mount=<path> suggestion into its own PR.
  • Explicitly skip run-cli tests that are broken with the Blueprints v2 runner but not needed for this PR.

@brandonpayton
Copy link
Member Author

I did the following:

  • Split the --auto-mount=path suggestion into its own PR here: Playground CLI: Support --auto-mount=path option #2525
  • Explicitly skipped run-cli tests that are still failing under Blueprints v2.
  • Added --mode tests, but the one for apply-to-existing-site is failing with an HTTP redirect when we expect the homepage to be served with a 200 response.

It looks like the failing apply-to-existing-site test is all that remains to be done.

- Fixed conflict in symlink test - preserved both HEAD and trunk functionality
- Fixed conflict in auto-mount tests - merged both versions properly
- Fixed TypeScript errors by changing autoMount from boolean to string
- All tests now work with both Blueprint v1 and v2 versions
@adamziel adamziel marked this pull request as ready for review August 26, 2025 17:45
@adamziel
Copy link
Collaborator

I've brushed up this PR, adjusted tests, and I think it's ready for merging.

@adamziel adamziel merged commit c5fb18d into trunk Aug 26, 2025
26 checks passed
@adamziel adamziel deleted the playground-cli-auto-select-blueprint-v2-modes branch August 26, 2025 17:53
@brandonpayton
Copy link
Member Author

I've brushed up this PR, adjusted tests, and I think it's ready for merging.

Thanks, @adamziel!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package][@wp-playground] CLI [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants